package com.wangzha.business.service;

import com.jfinal.plugin.activerecord.Db;
import com.jfinal.plugin.activerecord.Model;
import com.wangzha.common.base.service.BaseService;
import com.wangzha.common.model.Task;

import java.util.List;

public class TaskService extends BaseService {

    private Task dao = new Task().dao();

    @Override
    public Model<?> getDao() {
        return dao;
    }


    public List<Task> findByActiveCodeAndState(String activeCode, Integer state) {
        return dao.find("select * from task where active_code = ? AND state = ? order by id DESC LIMIT 1", activeCode, state);
    }

    public boolean updateStateById(Long id, Integer state) {
        return Db.update("update task set state = ? where id = ?", state, id) > 0 ? true : false;
    }

}
